//
//  UserModuleApi.m
//  DemoProject
//
//  Created by mouxiaochun on 16/3/17.
//  Copyright © 2016年 mmc. All rights reserved.
//

#import "UserModuleApi.h"


@implementation UserModuleApi
/**
 ** 用户注册
 ** phone:    手机号码
 ** code : 验证码
 ** type :0注册，1:忘记密码，2更换手机，3修改登录密码
 **
**/



+(void)driverRegiser:(NSString *)phone code:(NSString *)code password:(NSString *)password type:(NSString *)type completion:(AICompletionBlock)block{
  
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];

    NSString *unEncode = [NSString stringWithFormat:@"server=app/driver/driverRegiser&phone=%@&code=%@&password=%@&type=%@",phone,code,password,type];
    
  NSString *encodeKey =  [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];

    
 // NSDictionary *param = @{@"phone":phone,@"code":code,@"password":password,@"type":type};

  [UserModuleApi startRequest:_registerOfAction params:dic completion:block];
}

//验证码

+ (void)getValidCodeWithPhone:(NSString *)phone type:(NSString *)type state:(NSString *)state completion:(AICompletionBlock)block{
  
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];

     NSString *unEncode = [NSString stringWithFormat:@"server=app/smscheckcode/sendCheckCodeSms&phone=%@&type=%@&state=%@",phone,type,state];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
  
    [dic setObject:encodeKey forKey:@"key"];
    
    

 //   NSDictionary *param = @{@"phone":phone,@"type":type,@"state":state};

  
    [UserModuleApi startRequest:@"" params:dic completion:block];
    
}



/**
 ** 用户登录
 ** phone:    手机号码
 ** code : 验证码
 ** type :0注册，1:忘记密码，2更换手机，3修改登录密码
 **
 **/

+ (void)userLogin:(NSString *)phone password:(NSString *)password completion:(AICompletionBlock)block {
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driver/driverLogin&phone=%@&password=%@",phone,password];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
  
    
    [UserModuleApi startRequest:_loginOfAction params:dic completion:block];
    
}
/**
 ** 司机找回密码（1.0）
 ** phone:    手机号码
 ** smscode : 验证码
 ** type :验证码类型 ( 0注册，1:忘记密码，2更换手机，3修改登录密码 )
 **
 **/

+ (void)findPassword:(NSString *)phone smscode:(NSString *)smscode password:(NSString *)password type:(NSString *)type completion:(AICompletionBlock)block {
    
    //NSDictionary *param = @{@"phoneNo":phone,@"password":password};
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driver/driverForgetPassword&phone=%@&smscode=%@&password=%@&type=%@",phone,smscode,password,type];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [UserModuleApi startRequest:_userForgetPassword params:dic completion:block];
    
}

/**
 ** 司机修改头像（1.0）
 ** driverId:    手机号码
 ** smscode : 验证码
 ** type :验证码类型 ( 0注册，1:忘记密码，2更换手机，3修改登录密码 )
 **
 **/

+(void)chageHeaderUrl:(NSString *)driverId fileName0:(NSString *)fileName0 completion:(AICompletionBlock)block{
   
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driver/modifyTheAvatat&driverId=%@",driverId];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    NSString *url = URLSTRING;
    url=  [url stringByAppendingString:@"app/driver/modifyTheAvatat"];
//   [KKHttpClient afnetWorkingWithPath:url paramDic:dic andImagePathsArr:<#(NSArray *)#> andImageNamesArr:<#(NSArray *)#> andCallback:<#^(id obj)callback#> fail:<#^(id faile)fail#>]
 //   [UserModuleApi startRequest:_uploadHeadPic params:dic completion:block];



}

/**
 ** 司机修改个人信息（1.0）
 ** id:    司机id
 ** perInfo : 司机服务介绍
 ** autograph :签名介绍
 **
 **/

+(void)chageDriverInfo:(NSString *)id nickname:(NSString *)nickname sex:(NSString *)sex perInfo:(NSString *)perInfo autograph:(NSString *)autograph completion:(AICompletionBlock)block{

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driver/modifyDriverInfo&id=%@&nickname=%@&sex=%@&perInfo=%@&autograph=%@",id,nickname,sex,perInfo,autograph];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [UserModuleApi startRequest:_upLoadDriverInfomation params:dic completion:block];
   
}

+ (void)chageDriverperInfoWithId:(NSString *)id perInfo:(NSString *)perInfo completion:(AICompletionBlock)block{

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driver/modifyDriverInfo&id=%@&perInfo=%@",id,perInfo];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [UserModuleApi startRequest:_upLoadDriverInfomation params:dic completion:block];
    

    

}

+(void)chageDriverNickNameWithDriverId:(NSString *)id nickname:(NSString *)nickname completion:(AICompletionBlock)block{

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driver/modifyDriverInfo&id=%@&nickname=%@",id,nickname];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [UserModuleApi startRequest:_upLoadDriverInfomation params:dic completion:block];

}
+(void)chageDriversexWithId:(NSString *)id sex:(NSString *)sex completion:(AICompletionBlock)block{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driver/modifyDriverInfo&id=%@&sex=%@",id,sex];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [UserModuleApi startRequest:_upLoadDriverInfomation params:dic completion:block];

}
+(void)chageDriverAutographWithId:(NSString *)id autograph:(NSString *)autograph completion:(AICompletionBlock)block{
   
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driver/modifyDriverInfo&id=%@&autograph=%@",id,autograph];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [UserModuleApi startRequest:_upLoadDriverInfomation params:dic completion:block];


}
/**
 ** 司机修改绑定手机（1.0）
 ** driverId:    司机id
 ** type : 验证码类型   ( 0注册，1:忘记密码，2更换手机，3修改登录密码 )
 **
 **/
+(void)chageDriverWithDriverId:(NSString *)driverId oldTel:(NSString *)oldTel newTel:(NSString *)newTel codesms:(NSString *)codesms type:(NSString *)type completion:(AICompletionBlock)block{

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driver/modifyDriverPhone&driverId=%@&oldTel=%@&newTel=%@&codesms=%@&type=%@",driverId,oldTel,newTel,codesms,type];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [UserModuleApi startRequest:_bindPhoneOfAction params:dic completion:block];
    
    
    
}

/**
 ** 获取司机信息（1.0）
 ** driverId:    司机id
 **
 **/
+(void)getDriverInfo:(NSString *)driverId completion:(AICompletionBlock)block{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driver/getDriverInfo&driverId=%@",driverId];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [UserModuleApi startRequest:_queryUserInfo params:dic completion:block];
}
/**
 ** 修改司机登录密码（1.0）
 ** type:     ( 0注册，1:忘记密码，2更换手机，3修改登录密码 )
 **
 **/
+(void)changeDriverLoginPaw:(NSString *)driverId tel:(NSString *)tel oldpass:(NSString *)oldpass smscode:(NSString *)smscode newpass:(NSString *)newpass type:(NSString *)type completion:(AICompletionBlock)block{

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driver/modifyLoginPass&driverId=%@&tel=%@&oldpass=%@&smscode=%@&newpass=%@&type=%@",driverId,tel,oldpass,smscode,newpass,type];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [UserModuleApi startRequest:_uploadNewLoginPwd params:dic completion:block];


}


+(void)getDrivePingJiaWithDeiverId:(NSString *)driverId grade:(NSString *)grade pageIndex:(NSString *)pageIndex pageSize:(NSString *)pageSize completion:(AICompletionBlock)block{
  
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverCarInfo/getAllEavList&driverId=%@&grade=%@&pageIndex=%@&pageSize=%@",driverId,grade,pageIndex,pageSize];
    
    NSString *encodeKey = [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [UserModuleApi startRequest:_getAllEavList params:dic completion:block];



}

#pragma mark ---- 发起请求

+ (AIRequest *) startRequest:(NSString *)method params:(NSDictionary *)param completion:(AICompletionBlock)block {

    AIRequest *request = [AIRequest startWithRequestToURL:nil
                                                   method:method
                                                jsonParam:param
                                                  encrypt:NO
                                                    block:block];
    request.module = _userModuleName;
    
    return request;
}


//......  依次向下添加API

@end
